package csc.daonjpa.java.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import csc.daonjpa.java.dao.AccountDAO;
import csc.daonjpa.java.dao.CardDAO;
import csc.daonjpa.java.dao.CustomerDAO;
import csc.daonjpa.java.domain.Account;
import csc.daonjpa.java.domain.Card;
import csc.daonjpa.java.domain.Customer;


@Service
public class BankService {

	private AccountDAO accountDAO;

	public AccountDAO getAccountDAO() {
		return accountDAO;
	}

	@Autowired
	public void setAccountDAO(AccountDAO accountDAO) {
		this.accountDAO = accountDAO;
	}

	public void addAccount(Account account) {
		accountDAO.addAccount(account);
	}

	public List<Account> getAccounts() {
		return accountDAO.getAccounts();
	}

	public List<Account> getAccountsByCustomerId(String custLoginId) {
		return accountDAO.getAccountsByCustomerId(custLoginId);
	}

	private CustomerDAO customerDAO;

	public CustomerDAO getCustomerDAO() {
		return customerDAO;
	}

	@Autowired
	public void setCustomerDAO(CustomerDAO customerDAO) {
		this.customerDAO = customerDAO;
	}

	public boolean addCustomer(Customer customer) {
		return customerDAO.addCustomer(customer);
	}

	public List<Customer> getCustomers() {
		return customerDAO.getCustomers();
	}

	public Customer getCustomerByLoginInfo(String custId, String password) {
		return customerDAO.getCustomerByLoginInfo(custId, password);
	}

	public int changeCustomerPassword(String loginid, String newPassword) {
		return customerDAO.changeCustomerPassword(loginid, newPassword);
	}
	
	public int updateCustomerInfo(Customer customer) {
		return customerDAO.updateCustomerInfo(customer);
	}

	private CardDAO cardDAO;

	public CardDAO getCardDAO() {
		return cardDAO;
	}

	@Autowired
	public void setCardDAO(CardDAO cardDAO) {
		this.cardDAO = cardDAO;
	}

	public void addCard(Card card) {
		cardDAO.addCard(card);
	}

	public List<Card> getCards() {
		return cardDAO.getCards();
	}

	public List<Card> getCardsByCustomerId(String custLoginId) {
		return cardDAO.getCardsByCustomerId(custLoginId);
	}
}
